package com.aysafety.core.common;

import org.apache.commons.lang3.StringUtils;

import java.util.Map;

public class DataConversionUtil {

    public static String getStrFromMap(String key, Map<String, Object> map) {
        String value = "";
        if (map.get(key) != null) {
            value = map.get(key).toString();
        }
        return value;
    }

    public static String getStrFromMapOrSetDefaultValue(String key, String defaultValue, Map<String, Object> map) {
        if (map.get(key) != null) {
            String value = map.get(key).toString();
            if (StringUtils.isBlank(value)) {
                return defaultValue;
            } else {
                return value;
            }
        } else {
            return defaultValue;
        }
    }

}
